<!DOCTYPE html>
<html lang="en">

<head>
    <!-- <script src="http://code.jquery.com/jquery-2.1.4.min.js"></script> -->
    <script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
    <script src="https://code.jquery.com/jquery-3.0.0.min.js"></script>
    <!-- 百度压缩版引用地址: -->
    <script src="http://libs.baidu.com/jquery/2.1.4/jquery.min.js"></script>
    <!-- 微软压缩版引用地址: -->
    <script src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-2.1.4.min.js"></script>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Comment</title>
    <link rel="stylesheet" href="../css/comment.css">
    <link rel="stylesheet" href="../css/pingji_login.css">
</head>

<body>
    <div class="nav">
        <div class="head">
            <div class="head-img">
                <img src="../image/head1.jpeg" alt="ggggg" class="img">
            </div>
            
        </div>
        <div class="funcBar">
            <div class="choice">

            </div>
        </div>
    </div>
    <div class="login-container">
        <div class="login-card">
            <div id="login-card-title"><b>登录</b></div>
            <div id="login-card-container">
                <div id="login-card-container-login">
                    <div id="login-card-container-login-card">
                        <div id="id-login-mess">
                            <div class="login-mess"><div><b>用户名</b></div></div>
                            <div class="login-mess"><div><b>密码</b></div></div>
                        </div>
                        <div id="input-user-password">
                            <div class="login-input"><input type="text" name="username" id="input-username"></div>
                            <div class="login-input"><input type="password" name="password" id="input-password"></div>
                        </div>
                    </div>
                    <button id="button-submit">登录</button>
                </div>
                
            </div>
        </div>
    </div>
    <script>
        let hostPath = 'http://localhost:8081/';
        let btn = document.querySelector("#button-submit");
        btn.addEventListener('click', function () {
            console.log("点击注册");
            let input1 = document.querySelector("#input-username");
            let input2 = document.querySelector("#input-password");
            console.log(input1.value);
            if (input1.value == "" || input2.value == "" ) {
                alert("必填选项未填");
            }
            let obj={"username":input1.value,"password":input2.value};
            // 发送请求
            $.ajax({
                type :'POST',
                url: hostPath + 'login',  
                data: JSON.stringify(obj),
                contentType:"application/json",
                headers:{
                    'Access-Control-Allow-Origin':'*'
                },
                success: function (data) {
                    console.log("返回成功");
                    if(data.code==0){
                        document.location="pingji_order.html"+"?id="+data.id;
                    }
                    
                },
                error: function (data) {
                    alert(data.message);
                    console.log("error");
                }
            })
            
            
        });
        function checkPassword(password1, password2) {
            if (password1 == password2) {
                return true;
            }
            else {
                return false;
            }
        }
    </script>
</body>

</html>